<template>
  <div class="tab-control">
    <div  v-for="(item, index) in title"
          :key='index'
          class="tab-control-item"
          :class="{active: index===currentIndex}"
    >
      <span @click="itemClick(index)">{{item}}</span>
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      title: {
        type: Array,
        default() {
          return []
        }
      },
      currentIndex: {
        type: Number,
        default: 0
      }
    },
    methods: {
      itemClick(index) {
        console.log('点击了 index=',index)
        this.currentIndex = index
      }
    }
  }
</script>

<style scoped>


  .tab-control {
    width: 100%;
    background-color: white;
    display: flex;
    height: 40px;
    line-height: 40px;
    text-align: center;
    font-size: 15px;
  }

  .tab-control-item {
    flex: 1;
  }

  .active {
    color: var(--color-high-text);

  }

  .active span {
    padding-bottom: 5px;
    border-bottom: 3px solid var(--color-tint);
  }
</style>